/*
 * @Date: 2024-12-17 15:25:23
 * @Author: LiSong
 * @LastEditors: LiSong
 * @LastEditTime: 2024-12-17 15:55:58
 * @Description: 
 */
export const vResize = {
  mounted(el, binding) {
    binding.resizeObserver = null
    binding.resizeObserver = new ResizeObserver((entries) => {
      // Get the new width and height of the element
      const { width, height } = entries[0].contentRect;
      // Call the callback function with the new dimensions
      binding.value(width, height);
    });
    binding.resizeObserver.observe(el);
  },
  unmounted(el, binding) {
    if (!binding.resizeObserver) return
    binding.resizeObserver.unobserve(el);
  },
}